package com.mcptt.config.model;

import android.os.Parcel;
import android.os.Parcelable;

public class ImsInfo implements Parcelable
{
    private String impi = null;
    private String impu = null;
    private String realm = null;
    public ImsInfo(String impi,String impu,String realm)
    {
	this.impi = impi;
	this.impu = impu;
	this.realm = realm;
    }
    
    public boolean isInvalid()
	{
		if(this.impi == null
				|| this.impi.length() <= 0
				|| this.impu == null
				|| this.impu.length() <= 0
				|| this.realm == null
				|| this.realm.length() <= 0)
		{
			return true;
		}
		return false;
	}

    public boolean checkMustParamOk()
    {
	if(impi == null
		|| impi.length() <= 0)
	{
	    return false;
	}
	if(impu == null
		|| impu.length() <= 0)
	{
	    return false;
	}
//	if(psi == null
//		|| psi.length() <= 0)
//	{
//	    return false;
//	}
	return true;
    }
    public String getImpi()
    {
	return impi;
    }
    public String getImpu()
    {
	return impu;
    }
    public String getRealm()
    {
	return realm;
    }

    public String toString()
    {
	StringBuffer buffer = new StringBuffer("ImsInfo:");
	buffer.append("impi = ").append(impi).append(",");
	buffer.append("impu = ").append(impu).append(",");
	buffer.append("realm = ").append(realm).append(";");

	return buffer.toString();
    }
    
    public static final Parcelable.Creator<ImsInfo> CREATOR = new Parcelable.Creator<ImsInfo>() {
        public ImsInfo createFromParcel(Parcel in) {
            return new ImsInfo(in);
        }

        public ImsInfo[] newArray(int size) {
            return new ImsInfo[size];
        }
    };
    
    private ImsInfo(Parcel in) 
    {
    	 impi = getReadParcelableString(in.readString());
    	 impu = getReadParcelableString(in.readString());
    }
    
    private String getWriteParcelableString(String str) {
        return (str == null) ? "null" : str;
    }
    private String getReadParcelableString(String str) {
        return str.equalsIgnoreCase("null") ? null : str;
    }

	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		// TODO Auto-generated method stub
		dest.writeString(getWriteParcelableString(impi));
		dest.writeString(getWriteParcelableString(impu));
	}
}
